home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Add-Ons / MPW / MPW re2c 1.1 / examples / basemmap.c next >
Encoding:
C/C++ Source or Header  |  1995-06-01  |  499 b   |  27 lines  |  [TEXT/KAHL]

  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <sys/stat.h>
  4. #include <sys/mman.h>
  5. #include <string.h>
  6.  
  7. #ifndef    MAP_NORESERVE
  8. #define    MAP_NORESERVE    0
  9. #endif
  10.  
  11. volatile char ch;
  12.  
  13. main(){
  14.     struct stat statbuf;
  15.     uchar *buf;
  16.     fstat(0, &statbuf);
  17.     buf = mmap(NULL, statbuf.st_size, PROT_READ, MAP_SHARED|MAP_NORESERVE,
  18.     0, 0);
  19.     if(buf != (uchar*)(-1)){
  20.     uchar *cur, *lim = &buf[statbuf.st_size];
  21.     for(cur = buf; buf != lim; ++cur){
  22.         ch = *cur;
  23.     }
  24.     munmap(buf, statbuf.st_size);
  25.     }
  26. }
  27.